* recode the missing values as 0 for untreated districts -----------------------

replace mean_days = 0 if mean_days == .
replace min_days = 0 if min_days == .

* label the additional variables -----------------------------------------------

label variable mean_days           "Timing (Mean)"
label variable min_days            "Timing (Minimum)"

* run the regressions models and save them to memory ---------------------------

eststo: reg akp_nov treatment mean_days akp_jun recruitment_pool,               ///
cluster(province)

eststo: reg akp_nov treatment mean_days akp_jun recruitment_pool                ///
treatment_nonterror casualty_district kurdish_district akp_district             ///
higher_education min_margin turnout_jun, cluster(province)

eststo: reg akp_nov treatment min_days akp_jun recruitment_pool,                ///
cluster(province)

eststo: reg akp_nov treatment min_days akp_jun recruitment_pool                 ///
treatment_nonterror casualty_district kurdish_district akp_district             ///
higher_education min_margin turnout_jun, cluster(province)

* print the results ------------------------------------------------------------

esttab,                                                                         ///
replace se b(3) se(3) stats(N vce r2) label nodepvars nonotes nomtitles         ///
order(treatment mean_days min_days)                                             ///
substitute(vce "Clusters" cluster "81")                                         ///
title("Table S8: Regression models with treatment timing")

* save the results -------------------------------------------------------------

esttab using "./tables/table_s8.tex",                                           ///
replace se b(3) se(3) stats(N vce r2) label nodepvars nonotes nomtitles         ///
order(treatment mean_days min_days)                                             ///
substitute(vce "Clusters" cluster "81")                                         ///
title("Regression models with treatment timing")

* remove the models from memory ------------------------------------------------

eststo clear